<p>
  <b>User:</b>
  <%=h @plan.user_id %>
</p>

<p>
  <b>List:</b>
  <%=h @plan.list_id %>
</p>

<p>
  <b>Desc:</b>
  <%=h @plan.desc %>
</p>
<% p=0.0
   i=0 %>
<% form_for(@plan) do |f|  %>
<% end %>
<div style="text-align: center">
  <br/>
<table border="1px">
  <thead >
    <tr style="background-color: white; text-align: center;">
      <td >ลำดับ</td>
      <td >เวลา</td>
      <td >กิจกรรม</td>
    <td >สถานที่</td>
    <td >ค่าใช้จ่าย</td>
    </tr>
   </thead>
  <%@plan.listplans.find(:all,:order => 'datetime').each do |list| %>
  <tr>
    <%
    @subplan = nil
    if (list.typ_id == 1)||(list.typ_id ==nil)
    @subplan =  Subtourist.find(list.subtourist_id)
    end
    if(list.typ_id == 2)
    @subplan =  Subrest.find(list.subtourist_id)
    end
    if(list.typ_id == 3)
    @subplan =  Subresid.find(list.subtourist_id)
    end
    %>
    <% p +=@subplan.price.to_f
       i+=1 %>
    <td><%=i.to_s%></td>
   
    <% pdate = "p_date_and_time"+i.to_s %>
    <td> <%= calendar_date_select_tag pdate,list.datetime,:time => true %>
      <input  type="button"  onclick="updatetime('p_date_and_time<%=i%>','<%=list.id%>','<%=list.plan_id%>')" value="update"/>
    </td>
    <td><input id="p_desc<%=i%>" type="text" size="20" value="<%=list.desc%>"/><input type="button"  onclick="updatedesc('p_desc<%=i%>','<%=list.id%>','<%=list.plan_id%>')" value="update"/></td>
    <td><%= @subplan.name %></td>
    <td>ราคา:<%= @subplan.price %></td>
  </tr>
  <% end %>
  <tr>
    <td></td>
     <td></td>
     <td></td>
     <td>ราคารวม:</td>
     <td><%= p %></td>
  </tr>
</table>
</div>
<script >
 getauthenticity('edit_plan_<%=@plan.id%>');
</script>
<%= link_to 'Edit', edit_plan_path(@plan) %> |
<%= link_to 'Back', plans_path %>